<form class="form-horizontal" role="form" method="POST" id="addUserForm"
	action="/backend/user">

	<div class="form-group">
		<label class="col-sm-3 control-label">用户名</label>
		<div class="col-sm-7">
			<input type="text" class="form-control" name="user.username"
				placeholder="必填" required autofocus>
		</div>
	</div>
	<div class="form-group">
		<label class="col-sm-3 control-label">真实姓名</label>
		<div class="col-sm-7">
			<input type="text" class="form-control"
				name="user.realname" placeholder="必填" required>
		</div>
	</div>
	<div class="form-group">
		<label class="col-sm-3 control-label">密码</label>
		<div class="col-sm-7">
			<input type="password" class="form-control" name="user.password"
				placeholder="必填" required >
		</div>
	</div>
	<div class="form-group">
		<label class="col-sm-3 control-label">手机号码</label>
		<div class="col-sm-7">
			<input type="number" class="form-control" name="user.phone"
				placeholder="可填">
		</div>
	</div>
	<div class="form-group">
		<label class="col-sm-3 control-label">角色</label>
		<div class="col-sm-9">
			<select class="form-control" name="user.role_code">
			  <option v-for="x in roles" value="{{x.code}}">{{x.name}}</option>
			</select>
		</div>
	</div>
	<div class="form-group">
		<label class="col-sm-3 control-label">组织机构</label>
		<div class="col-sm-9">
			<select class="form-control" name="user.org_code">
			  <option v-for="x in orgs" value="{{x.code}}">{{x.name}}</option>
			</select>
		</div>
	</div>
	<div class="form-group">
		<label class="col-sm-3 control-label">职位</label>
		<div class="col-sm-9">
			<select class="form-control" name="user.position_code">
			  <option v-for="x in positions" value="{{x.code}}">{{x.name}}</option>
			</select>
		</div>
	</div>
	<div class="modal-footer">
		<button class="btn btn-success x" style="success" type="submit">确定</button>
		<button class="btn btn-danger x" style="danger" data-dismiss="modal">取消</button>
	</div>
</form>
<script>
new Vue({
	el:"#addUserForm",
	data:{
		roles:[],
		orgs:[],
		positions:[]
	},
	ready:function(){
		this.$http.get('/backend/role').then(function(resp){
			this.roles=resp.data.items;
		});
		this.$http.get('/backend/org').then(function(resp){
			var items=resp.data.items;
			var _space="--";
			for(var i=0;i<items.length;i++){
				var space="";
				for(var j=0;j<items[i].level;j++){
					space+=_space;
				}
				items[i].name=space+items[i].name;
			}
			this.orgs=items;
		});
		this.$http.get('/backend/position').then(function(resp){
			this.positions=resp.data.items;
		});
	}
}) 
	
</script>